/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fr.sorbonne.soa.lib;

import fr.sorbonne.soa.entity.Manufacturerinfo;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Nairo
 */
@Stateless
public class ManufacturerinfoFacade implements ManufacturerinfoFacadeLocal {
    @PersistenceContext
    private EntityManager em;

    public void create(Manufacturerinfo manufacturerinfo) {
        em.persist(manufacturerinfo);
    }

    public void edit(Manufacturerinfo manufacturerinfo) {
        em.merge(manufacturerinfo);
    }

    public void remove(Manufacturerinfo manufacturerinfo) {
        em.remove(em.merge(manufacturerinfo));
    }

    public Manufacturerinfo find(Object id) {
        return em.find(Manufacturerinfo.class, id);
    }

    public List<Manufacturerinfo> findAll() {
        return em.createQuery("select object(o) from Manufacturerinfo as o").getResultList();
    }

    public List<Manufacturerinfo> findManufacturerByProduct1(String productTypeId) {
        return em.createQuery("select object(o) from Manufacturerinfo as o where o.product1 =" + productTypeId).getResultList();
    }

    public List<Manufacturerinfo> findManufacturerByProduct2(String productTypeId) {
        return em.createQuery("select object(o) from Manufacturerinfo as o where o.product2 =" + productTypeId).getResultList();
    }

    public List<Manufacturerinfo> findManufacturerByProduct3(String productTypeId) {
        return em.createQuery("select object(o) from Manufacturerinfo as o where o.product3 =" + productTypeId).getResultList();
    }

}
